/*
 * @(#)CodedElementTransformer.java
 * Date 2013-08-16
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.pix.transformer;

import javax.enterprise.context.ApplicationScoped;
import org.hl7.v3.CD;

import us.hornerscorners.lamppost.model.common.CodedElement;
import us.hornerscorners.lamppost.model.common.LocalizedString;

import us.hornerscorners.lamppost.transformer.AbstractTransformer;


/**
 *
 * @author jim
 */
@ApplicationScoped
public class CodedElementTransformer extends AbstractTransformer<CD, CodedElement> {

    /**
     * Constructs ...
     *
     */
    public CodedElementTransformer() {
        super();
    }

    /**
     * Method description
     *
     *
     * @param prpaCodedElement
     *
     * @return
     */
    @Override
    public CodedElement transform(CD prpaCodedElement) {

        CodedElement result = null;

        if (prpaCodedElement != null) {

            result = new CodedElement();
            result.setCode(prpaCodedElement.getCode());
            result.setCodeSystem(prpaCodedElement.getCodeSystem());
            result.setCodeSystemName(prpaCodedElement.getCodeSystemName());
            result.setCodeSystemVersion(prpaCodedElement.getCodeSystemVersion());
            result.getDisplayNames().add(
                new LocalizedString(prpaCodedElement.getDisplayName()));
        }

        return result;
    }
}
